#!/usr/local/bin/python3
# *_* coding: UTF-8 *_*
# @IDE: PyCharm
# @Version: Python3.97
# @Author: Kendrick.Kc
# @Email: 509556985@qq.com
# @File: db_cache.py
# @Inst: 这里是模块名描述
# @Time: 2023/6/23 14:24
# -----


from django.core.cache import cache


class DBCache:

    def __init__(self, title):
        self.title = title

    def cache_set(self, item, content, time_out=None):
        """
        设置
        :param item: 标题
        :param content: 内容
        :param time_out: 超时
        :return:
        """
        cache.set(f"{self.title}_{item}", content, time_out)

    def cache_get(self, item):
        """
        获取
        :param item: 标题
        :return:
        """
        return cache.get(f"{self.title}_{item}")

    def cache_delete(self, item):
        """
        删除
        :param item: 标题
        :return:
        """
        return cache.delete(f"{self.title}_{item}")

    @staticmethod
    def cache_clear():
        cache.clear()
